package org.dftproject.patml.factories;

import org.dftproject.genesis.core.persistence.IMemento;
import org.dftproject.genesis.core.persistence.IPersistenceFactory;
import org.dftproject.genesis.core.persistence.PersistenceUtils;
import org.dftproject.patml.data.PatmlPerson;
import org.dftproject.patml.data.PatmlSite;

public class PatmlPersonFactory implements IPersistenceFactory {

	public static final String ID = PatmlPersonFactory.class.getName();
	
	public Object createObject(IMemento memento) {
		IPersistenceFactory factory = PersistenceUtils.getFactory(memento.getString("siteFactoryId"));
		Object site = factory.createObject(memento.getChild("site"));
		if (site instanceof PatmlSite)
			return new PatmlPerson((PatmlSite) site, memento.getString("id"));
		return null;
	}

}
